﻿Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.DirectiveSearchForm = function (config) {
    Ext.apply(this, config);
    var organizationStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/DirectiveViewService.aspx?Action=GetOrganization'
        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Name',
            fields: ['Name', 'Id', 'Code']
        }),
        remoteStore: true
    });
    organizationStore.load();

    var organizationComboBox = new Ext.form.ComboBox({
        fieldLabel: '部门',
        name: 'Organization',
        hiddenName: 'Organization',
        store: organizationStore,
        displayField: 'Name',
        mode: 'local',
        valueField: 'Name',
        editable: false,
        triggerAction: 'all',
        emptyText: '选择部门',
        readOnly: true,
        anchor: '90%'

    });
    var typeComBox = new Ext.form.ComboBox({
        fieldLabel: '调警类型',
        store: new Ext.data.SimpleStore({
            fields: ['Code', 'Ttext'],
            data: [
                                   ['机关警力遏制街面两抢发案', '机关警力遏制街面两抢发案'],
                                    ['巡警强化街面整体防控', '巡警强化街面整体防控'],
                                    ['派出所高峰复杂区域防控', '派出所高峰复杂区域防控'],
                                    ['派出所遏制入室盗高发防控', '派出所遏制入室盗高发防控'],
                                    ['派出所遏制机动车盗抢防控', '派出所遏制机动车盗抢防控'],
                                    ['派出所临时治安检查点防控', '派出所临时治安检查点防控']
                                            ]
        }),
        name: 'Code',
        blankText: '请选指令类型',
        id: 'module',
        mode: 'local',
        valueField: 'Code',
        triggerAction: 'all',
        displayField: 'Ttext',
        readOnly: true,
        anchor: '90%'
    });
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [{

            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [organizationComboBox]
        }, {
            columnWidth: 1,
            layout: 'form',
            border: false,
            items: [new FantastPlatform.UI.DateField({
                fieldLabel: '布警时间',
                name: 'StartTime',
                format: 'Y-m-d',
                width: 150,
                dateConfig: {}
            })]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [typeComBox]
        }]
    }];
    FantastPlatform.UI.DirectiveSearchForm.superclass.constructor.call(this, {
        bodyStyle: 'padding-top:25px',
        collapsible: true,
        labelAlign: 'right',
        buttonAlign: 'center',
        autoScroll: false
    });
};
Ext.extend(FantastPlatform.UI.DirectiveSearchForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.DirectiveSearchForm.superclass.onRender.call(this, ct, position);
    },
    submitSearchFormJson: function (form, grid, sender, data) {
        if (form.form.isValid()) {

            var dataStr = Ext.util.JSON.encode(form.form.getValues());
            grid.store.baseParams = {
                data: dataStr
            }
            grid.store.removeAll();
            grid.store.proxy.conn = { method: 'post', url: form.url };
            grid.store.load({ params: { start: 0, limit: grid.paperBar.getPageNumber(), dir: '', sort: '', data: dataStr} });
            if (sender)
                sender.close();

        }
    }

});